<div class="adPosts">
<h2><?php __('All Classified Ads');?></h2>
<p>&nbsp;</p>
<table cellpadding="0" cellspacing="0" style="margin:0;">
  <tr>
	<th class="normal" style="border:0; width:60%;"><?php
echo $paginator->counter(array(
    'format' => __('Showing %start% - %end% of %count% ads ', true)
));
?></th>
	<th style="border:0;"><?php __('Price'); ?></th>
	<th style="border:0;"><?php __('location'); ?></th>
	<th style="border:0;"><?php __('Posted'); ?></th>
  </tr>
<?php
$i   = 0;
$tmp = null;
foreach ($adPosts as $adPost):
	$class = null;
    $date1 = substr($adPost['AdPost']['created'], 0, 10);
	if ($i++ % 2 == 0) {
		$class = ' class="altrow"';
	}
    if ($tmp != $date1) {
        if ($time->isToday($adPost['AdPost']['created'])) {
            $date  = __('Today', true);
            $today = true;
        } else if ($time->wasYesterday($adPost['AdPost']['created'])) {
            $date = __('Yesterday', true);
            $today = false;
        } else {
            $date = $time->format('l, F j, Y', $adPost['AdPost']['created'], false, 8);
            //$date = $time->nice($adPost['AdPost']['created']);
            $today = false;
        }
        $tmp = $date1;
?>
    <tr>
      <td colspan="4" style="padding-top:13px;"><span class="date"><?php echo $date; ?></span></td>
    </tr>
<?php } ?>
	<tr<?php echo $class;?>>
		<td style="border-top:1px solid #ddd; padding-top:10px;">
          <b><?php ($adPost['AdPost']['type'] == 'W') ? __('Wanted:') : '' ; ?>
          <?php echo $html->link($adPost['AdPost']['title'], '/adPosts/view/'.$adPost['AdPost']['id']); ?></b>
		</td>
		<td style="border-top:1px solid #ddd; padding-top:10px;">
			<?php echo $adPost['AdPost']['price']; ?>
		</td>
		<td style="border-top:1px solid #ddd; padding-top:10px;">
			<?php echo $adPost['AdPost']['location']; ?>
		</td>
		<td style="border-top:1px solid #ddd; padding-top:10px;">
			<?php echo ($today) ? '&lt; '.$time->timeAgoInWords($adPost['AdPost']['created']) : $time->format('g:ia', $adPost['AdPost']['created'], false, 8); ?>
		</td>
	</tr>
    <tr<?php echo $class;?>>
      <td>
        <table style="margin-bottom:10px;">
          <tr>
<?php if ($adPost['DefaultImage']['filename']) { ?>
            <td valign="top" style="padding:0;">
              <a href="<?php echo $this->base; ?>/adPosts/view/<?php
               echo $adPost['AdPost']['id']; ?>" style="display:block;"><img src="<?php
               echo $this->base; ?>/img/images/s_<?php echo $adPost['DefaultImage']['filename']; ?>" class="thumb" /></a>
            </td>
<?php } ?>
            <td valign="top" style="padding:0 0 0 5px; vertical-align:top;">
              <span style="font-size:11px;"><?php echo $text->truncate($adPost['AdPost']['description']); ?></span>
            </td>
          </tr>
        </table>
      </td>
      <td colspan="3">&nbsp;</td>
    </tr>
<?php endforeach; ?>
</table>
</div>
<div class="paging">
    <?php __('Page:');?>
	<?php echo $paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));?>
    <?php echo $paginator->numbers();?>
	<?php echo $paginator->next(__('next', true).' >>', array(), null, array('class'=>'disabled'));?>
</div>
